﻿<%@ Page Language="C#" MasterPageFile="~/Layouts/List.Master" AutoEventWireup="true" CodeBehind="RoleUser.aspx.cs" Inherits="Bingosoft.WebApp.Modules.SecurityConsole.Role.RoleUser" %>
<%@ Import Namespace="Bingosoft.Modules.SecurityConsole.Common.Helper" %>
<%@ Import Namespace="Bingosoft.Web.Utils" %>

<asp:Content ContentPlaceHolderID="head" ID="idFormTitle" runat="server">
<web:Script ID="Script1" src="~/Modules/SecurityConsole/Common/FunctionControl/TreeListSelect/TreeListSelectObject.js" runat="server" />
    <title>分配用户</title>  
</asp:Content>

<asp:Content ID="idContent" ContentPlaceHolderID="Content" runat="Server">   
<script type="text/javascript">
    var Global = {};
    Global.contextPath = '<%=RequestHelper.GetContextPath(Request)%>';
</script>
    <!-- 搜索框 -->
    <asp:HiddenField ID="UserIds" runat="server" />
	<div class="search" style="margin-top:0px;">
     <web:search ID="GridSearch" GridViewId="SmartGridView1" runat="server">            
            <SearchConditionTemplate>                                       
               <table cellpadding="0" cellspacing="0" width="95%">
			<tr>
                <th>
                    用户名称：
                </th>
	            <td>
		            <asp:TextBox ID="Name" name="Name" runat="server"></asp:TextBox>
	            </td>
                <th>
                    用户账号：
                </th>
	            <td>
		            <asp:TextBox ID="LoginId" name="LoginId" runat="server"></asp:TextBox>
	            </td>             
            </tr>
			            
        </table>
            </SearchConditionTemplate>                      
        </web:search>
       
    </div>

    <div class="datalist">
	    <!-- 标题头 -->
	    <h2 style="height:30px;">
				    【<%=Request.Params["RoleName"]%>】已分配用户
	    </h2>
	    <!-- 工具栏 -->
	    <div class="toolbar"  style="height:30px;">
            <asp:LinkButton runat="server"
                OnClientClick="return addUsers();" OnClick="AddUsersForRole">
                <span>
                    <img alt="" runat="server" id="img1" src="~/Images/icon_new.gif" style="border: 0px" />添加用户
                </span>
            </asp:LinkButton>    
            <asp:LinkButton ID="LinkButton1" runat="server"
                OnClientClick="return delUserRoles();" OnClick="DelUserRoles">
                <span>
                    <img id="Img2" alt="" runat="server" src="~/Images/ico_del.gif" style="border: 0px" />删除用户
                </span>
            </asp:LinkButton>        
	    </div>
	    <div class="datagrid"  style="clear:left;">    
            <!--------------------------- List Area --------------------------->
            <web:SmartGridView ID="SmartGridView1" runat="server" AutoGenerateColumns="False"
                Width="100%" DataKeyNames="Id" DataSourceID="SmartDataSource1" PageSize="9">
                <Columns>  
                    <asp:CheckBoxField DataField="Id"/> 
                    <asp:BoundField DataField="Name" HeaderText="用户名称" SortExpression="Name" ItemStyle-HorizontalAlign="Left"/>
                    <asp:BoundField DataField="LoginId" HeaderText="用户账号" SortExpression="LoginId" ItemStyle-HorizontalAlign="Left"/>
                    <asp:BoundField DataField="OrgName" HeaderText="所在组织" SortExpression="OrgName" ItemStyle-HorizontalAlign="Left" />
                    <asp:BoundField DataField="TypeName" HeaderText="帐号类型" SortExpression="TypeName" ItemStyle-HorizontalAlign="Center" />
                    <asp:BoundField DataField="MobilePhone" HeaderText="手机号码" SortExpression="MobilePhone" ItemStyle-HorizontalAlign="Left" />
                    <asp:BoundField DataField="StatusName" HeaderText="状态" SortExpression="StatusName" ItemStyle-HorizontalAlign="Center" />
                </Columns>
                <CheckBoxSettings Enabled="True" Position="0" />
                <PagerSettings />
                <EditRowStyle HorizontalAlign="Center" />
            </web:SmartGridView>
    
            <web:SmartSqlDataSource ID="SmartDataSource1" runat="server" SelectCommand="role.role_user_list"
            SelectCommandAutoPageWrap="true" DefaultSortExpression="Id desc">       
            </web:SmartSqlDataSource>
        </div>
	</div>
    <div class="footer">
        <asp:Button ID="CloseButton2" runat="server" Text="关闭" OnClientClick="window.close();return false;" />        
	</div>
    <script type="text/javascript">
        var RoleId = "<%=Request.Params["RoleId"]%>";
        //打开用户选择页面并传递
        function addUsers() {
            var treeListSelect = new TreeListSelect();
            treeListSelect.setTreeRootSqlId("organization.firstFloor.tree");
            treeListSelect.setTreeChildSqlId("organization.getChildren");
            treeListSelect.setTitle("组织机构");
            treeListSelect.setTreeAsyn("true");
            treeListSelect.setTreeRootText("组织机构");
            treeListSelect.setTreeRootId("root");
            treeListSelect.setListDataService("TreeListSelectService");
            treeListSelect.setListSqlId("role.userSelect.user_list");
            treeListSelect.setParams("ROLE_ID:" + RoleId);

            var returnValue = treeListSelect.show(Global.contextPath);

            if (returnValue && returnValue.length == 2) {
                $("#<%=ControlHelper.FindControl(this.Page, "UserIds").ClientID%>").val(returnValue[0]);
                return true;
            }
            return false;
        }


        function delUserRoles() {
            var oSmartGridView1 = document.getElementById("<%=SmartGridView1.ClientID%>");
            var sValues = oSmartGridView1.control.getCheckedValues(true);

            if (sValues && sValues.length > 0) {

                return confirm('您确认要删除吗?');
            }

            alert("请您选择要删除的用户！");

            return false;
        }    

    </script>
</asp:Content>